<?php namespace Phpcmf\Controllers\Admin;

class Category extends \Phpcmf\Admin\Category
{

    public function index() {
		$table = \Phpcmf\Service::M()->prefix.SITE_ID.'_'.$mid;
		$ctable = $table.'quan_category';
		        
		if (\Phpcmf\Service::M()->db->tableExists($ctable) && !\Phpcmf\Service::M()->db->fieldExists('zuobian', $ctable)) {
		    \Phpcmf\Service::M()->query('ALTER TABLE `'.$ctable.'` ADD `zuobian` int(3) DEFAULT \'0\' COMMENT \'左边\'');
		}
		if (\Phpcmf\Service::M()->db->tableExists($ctable) && !\Phpcmf\Service::M()->db->fieldExists('dingbu', $ctable)) {
		    \Phpcmf\Service::M()->query('ALTER TABLE `'.$ctable.'` ADD `dingbu` int(3) DEFAULT \'0\' COMMENT \'顶部\'');
		}
		$zuobianfield = \Phpcmf\Service::M()->db->table('field')->where('relatedname', 'category-quan')->where('relatedid', 0)->where('fieldname', 'zuobian')->countAllResults();
		if (!$zuobianfield) {
			\Phpcmf\Service::M()->db->table('field')->insert(array(
			'name' => '左边',
			          'fieldname' => 'zuobian',
			          'fieldtype' => 'Radio',
					  'relatedid' => 0,
					  'relatedname' => 'category-quan',
			          'isedit' => '1',
			          'ismain' => '1',
			          'issystem' => '0',
			          'ismember' => '0',
			          'issearch' => '0',
			          'disabled' => '0',
			          'setting' => 
					  dr_array2string(array (
			            'option' => 
			            array (
		              'options' => '隐藏|0
		显示|1',
		              'is_field_ld' => '0',
		              'value' => '0',
		              'fieldtype' => '',
		              'fieldlength' => '',
		              'show_type' => '0',
		              'css' => '',
			            ),
			            'validate' => 
			            array (
			              'xss' => '1',
			              'required' => '0',
			              'pattern' => '',
			              'errortips' => '',
			              'check' => '',
			              'filter' => '',
			              'tips' => '',
			              'formattr' => ' data-role="tagsinput"',
			            ),
			            'is_right' => '0',
						'show_member' => 
							array (
							  0 => '2',
							),
			          )),
			          'displayorder' => '0',
			));
		}
		$dingbufield = \Phpcmf\Service::M()->db->table('field')->where('relatedname', 'category-quan')->where('relatedid', 0)->where('fieldname', 'dingbu')->countAllResults();
		if (!$dingbufield) {
			\Phpcmf\Service::M()->db->table('field')->insert(array(
			'name' => '顶部',
			          'fieldname' => 'dingbu',
			          'fieldtype' => 'Radio',
					  'relatedid' => 0,
					  'relatedname' => 'category-quan',
			          'isedit' => '1',
			          'ismain' => '1',
			          'issystem' => '0',
			          'ismember' => '0',
			          'issearch' => '0',
			          'disabled' => '0',
			          'setting' => 
					  dr_array2string(array (
			            'option' => 
			            array (
		              'options' => '隐藏|0
		显示|1',
		              'is_field_ld' => '0',
		              'value' => '0',
		              'fieldtype' => '',
		              'fieldlength' => '',
		              'show_type' => '0',
		              'css' => '',
			            ),
			            'validate' => 
			            array (
			              'xss' => '1',
			              'required' => '0',
			              'pattern' => '',
			              'errortips' => '',
			              'check' => '',
			              'filter' => '',
			              'tips' => '',
			              'formattr' => ' data-role="tagsinput"',
			            ),
			            'is_right' => '0',
						'show_member' => 
							array (
							  0 => '2',
							),
			          )),
			          'displayorder' => '0',
			));
		}
        $this->_Admin_List();
    }

    public function all_add() {
        $this->_Admin_All_Add();
    }

    public function add() {
        $this->_Admin_Add();
    }

    public function edit() {
        $this->_Admin_Edit();
    }

    public function url_edit() {
        $this->_Admin_Url_Edit();
    }

    public function move_edit() {
        $this->_Admin_Move_Edit();
    }
    
    public function show_edit() {
        $this->_Admin_Show_Edit();
    }
    
    public function displayorder_edit() {
        $this->_Admin_Order();
    }
    
    public function html_edit() {
        $this->_Admin_Html_Edit();
    }

    public function del() {
        $this->_Admin_Del();
    }
}
